﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElteIk.RoboSoccer.Core.Physics
{
    /// <summary>
    /// A simple class for 2D vector pairs.
    /// </summary>
    public sealed class FreeVector2D
    {
        #region Lifecycle

        public FreeVector2D(float a1, float a2, float b1, float b2)
        {
            start = new Vector2D(a1, a2);
            end = new Vector2D(b1, b2);
        }

        public FreeVector2D(FreeVector2D vector)
            : this(vector.start.X, vector.start.Y, vector.end.X,vector.end.Y)
        {
        }

		/// <summary>
		/// Vector2D as an origo-based FreeVector.
		/// </summary>
		/// <param name="vector"></param>
		public FreeVector2D(Vector2D vector)
			: this(Vector2D.NullVector, vector)
		{
		}

        public FreeVector2D(Vector2D start, Vector2D end)
            : this(start.X, start.Y, end.X, end.Y)
        {
        }

        public FreeVector2D()
            : this(0.0f, 0.0f, 0.0f, 0.0f)
        {
        }

        #endregion

        #region Properties

        private Vector2D start;
        public Vector2D Start
        {
            get { return start; }
            set { start = value; }
        }

        private Vector2D end;
        public Vector2D End
        {
            get { return end; }
            set { end = value; }
        }

        /// <summary>
        /// True if the first (start) vector of the FreeVector is a null vector.
        /// </summary>
		public bool IsOrigoBased
		{
			get
			{
				return start.Equals(Vector2D.NullVector);
			}
		}

        /// <summary>
        /// The length of the free vector. (Subtracting end from start)
        /// </summary>
        public float Length
        {
            get
            {
                return (end - start).Length;
            }
        }

        #endregion
    }
}
